package com.leyou.lyitem.service.impl;

import com.leyou.item.pojo.Category;
import com.leyou.lyitem.mapper.CategoryMapper;
import com.leyou.lyitem.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<Category> queryListByParent(Long pid) {
        Category category = new Category();
        category.setParentId(pid);
        return this.categoryMapper.select(category);
    }

    @Override
    public int addCategoryByParent(Category category) {

        return this.categoryMapper.insert(category);

    }

    @Override
    public int deleteCategoryByParent(Long id) {
        return this.categoryMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int editCategoryByParent(Category category) {
        return this.categoryMapper.updateByPrimaryKeySelective(category);
    }

}
